package servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import dao.WebUserDAO;
import entity.WebUser;

@WebServlet("/passwordedit")
public class UserPassServlet  extends HttpServlet{
	private WebUserDAO dao = new WebUserDAO();
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        //TODO Method stub generated by Lomboz
        this.doPost(request, response);
    }
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String method = request.getParameter("method");
        String result = "";
        result= Userpass_edit(request);
        RequestDispatcher dispatcher = request.getSession().getServletContext()
                .getRequestDispatcher(result);
        if (dispatcher != null)
            dispatcher.forward(request, response);
    }
	private String Userpass_edit(HttpServletRequest request) {
		 try {
			 String userno=request.getParameter("userno");
			 String password= request.getParameter("newpass");
			 this.dao.Userpass_edit(userno,password);
			 return "/photo.jsp";
	        } catch (Exception ex) {
	            request.setAttribute("errormsg", ex.getMessage());
	            return "/error.jsp";
	        }
	}
}
